package pnu.ssm.model.stuff;

import pnu.ssm.model.GPosition;
import pnu.ssm.model.tile.TileEnum;

public abstract class Stuff {
	private GPosition pos;
	private String name;
	private TileEnum state;
	
	public Stuff(String name, GPosition pos, TileEnum state) {
		this.name = name;
		this.pos = pos;
		this.state = state;
	}
	
	public TileEnum getState() {
		return state;
	}

	public void setState(TileEnum state) {
		this.state = state;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}	
	public GPosition getPos(){
		return pos;
	}
	public void setPos(GPosition pos){
		this.pos = pos;
	}
	public int getDistance(Stuff otherStuff) {
		GPosition otherPos = otherStuff.getPos();
		return getRectilinearDistance(otherPos);
	}
	
	private int getRectilinearDistance(GPosition otherPos){
		return Math.abs(otherPos.getX() - pos.getX()) + Math.abs(otherPos.getY() - pos.getY());
	}
	
	private int pythagorasDistance(GPosition otherPos){
		return (int) Math.sqrt( (otherPos.getX()-pos.getX()) * (otherPos.getX()-pos.getX()) 
		+ (otherPos.getY()-pos.getY()) * (otherPos.getY()-pos.getY()));
	}
	
	@Override
	public String toString() {
		return name;
	}
}
